package test4;

public class A4 {
    public static void main(String[] args) {
        // 创建商品
        Product product1 = new Product(10.0, 1.5, "巧克力豆", "Description 1");
        Product product2 = new Product(15.0, 2.0, "盒子蛋糕", "Description 2");

        // 创建订单详情
        OrderDetail orderDetail1 = new OrderDetail(product1, 2);
        OrderDetail orderDetail2 = new OrderDetail(product2, 3);

        // 创建订单
        Order order = new Order("2023-10-20", "PAID");
        order.addOrderDetail(orderDetail1);
        order.addOrderDetail(orderDetail2);



        // 创建客户
        Customer customer = new Customer("张程茜", "18307151951", "宜昌市西陵区三峡大学", true);
        customer.placeOrder(order);
        // 创建信用卡支付方式
        Credit creditPayment = new Credit(order.calculateTotal(), "6213360779984499679", "农业银行", "12月25日");
        order.setPayment(creditPayment);

        System.out.println("Customer: " + customer.getName());
        System.out.println("Number of Orders: " + customer.getOrders().size());
        for (Order customerOrder : customer.getOrders()) {
            System.out.println("Order Date: " + customerOrder.getCreateDate());
            System.out.println("Order Status: " + customerOrder.getStatus());
            for (OrderDetail orderDetail : customerOrder.getOrderDetails()) {
                Product product = orderDetail.getProduct();
                System.out.println("Product: " + product.getName());
                System.out.println("Quantity: " + orderDetail.getQuantity());
                System.out.println("Subtotal: $" + orderDetail.calculateSubTotal());
            }
            Payment payment = customerOrder.getPayment();
            if (payment instanceof Credit) {
                Credit credit = (Credit) payment;
                System.out.println("支付方式  "+credit.getPaymentDetails());
            } else if (payment instanceof Cash) {
                Cash cash = (Cash) payment;
                System.out.println("支付方式  "+cash.getPaymentDetails());
            } else if (payment instanceof WireTransfer) {
                WireTransfer wireTransfer = (WireTransfer) payment;
                System.out.println("支付方式  "+wireTransfer.getPaymentDetails());
            } else if (payment instanceof AliPay) {
                AliPay aliPay = (AliPay) payment;
                System.out.println("支付方式  "+aliPay.getPaymentDetails());
            } else if (payment instanceof WeixinPay) {
                WeixinPay weixinPay = (WeixinPay) payment;
                System.out.println("支付方式  "+weixinPay.getPaymentDetails());
            }
            System.out.println("Total Order Amount: $" + customerOrder.calculateTotal());
            System.out.println("----------------------------");
        }
    }

}










